package com.boyadegroot.divelog.models;

import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;

public class DiveCenter implements Parcelable, Comparable<DiveCenter> {

    private static final String TAG = DiveCenter.class.getName();

    private long mId;
    private String mName;
    private DiveLocation mLocation;
    private String mWebsite;

    public DiveCenter() {}

    public DiveCenter(long id, String name, DiveLocation location, String website) {
        this.setId(id);
        this.setName(name);
        this.setLocation(location);
        this.setWebsite(website);
    }

    public long getId() {
        return mId;
    }

    public void setId(long id) {
        this.mId = id;
    }

    public String getName() {
        return mName;
    }

    public void setName(String name) {
        this.mName = name;
    }

    public DiveLocation getLocation() {
        return mLocation;
    }

    public void setLocation(DiveLocation location) {
        this.mLocation = location;
    }

    public String getWebsite() {
        return mWebsite;
    }

    public void setWebsite(String website) {
        this.mWebsite = website;
    }

    @Override
    public int compareTo(@NonNull DiveCenter another) {
        return this.mName.compareTo(another.mName);
    }

    @Override
    public String toString() {
        return getName();
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(mId);
        dest.writeString(mName);
        dest.writeParcelable(mLocation, flags);
        dest.writeString(mWebsite);
    }

    public static final Parcelable.Creator<DiveCenter> CREATOR = new Parcelable.Creator<DiveCenter>() {

        public DiveCenter createFromParcel(Parcel in) {
            return new DiveCenter(in);
        }

        public DiveCenter[] newArray(int size) {
            return new DiveCenter[size];
        }
    };

    private DiveCenter(Parcel in) {
        mId = in.readLong();
        mName = in.readString();
        mLocation = in.readParcelable(DiveLocation.class.getClassLoader());
        mWebsite = in.readString();
    }
}
